---@class SpawnPositionType
SpawnPositionType = ClientFight.CreateClass("SpawnPositionType")
function SpawnPositionType:ctor(id,name)
    self.id = id
    self.name = name.."["..id.."]"
end
local map = {}
function SpawnPositionType:valueOf(id)
    return map[id]
end
---@return SpawnPositionType
local function ADD_VALUE(type,id,name)
    local e = SpawnPositionType.New(id,name)
    map[e.id] = e
    SpawnPositionType[type] = e
    return e
end

function SpawnPositionType:action( fighter, skill,params)

end
---召唤者出战位置
local type1 = ADD_VALUE("type1",1, "召唤者出战位置")
---@param fighter Fighter
---@param skill FightUsingSkill
---@param params number[]
function type1:action( fighter, skill,params)
    local pos = fighter.fight.fightSites[fighter.teamIndex][fighter.site];
    return Vector2(pos[1], pos[3]);
end
---以目标为中心 XY偏移
local type2 = ADD_VALUE("type2",2, "XY偏移")
---@param fighter Fighter
---@param skill FightUsingSkill
---@param params number[]
function type2:action( fighter, skill,params)
    local xOffset = params[2];
    local yOffset = params[3];
    local base = skill.target.position;
    local direction = FighterUtils.getTeamSiteDirection(skill.target);
    return Vector2(base.x + xOffset * direction, base.y + yOffset * direction);
end
---配置出战位置
local type3 = ADD_VALUE("type3",3, "配置出战位置")
---@param fighter Fighter
---@param skill FightUsingSkill
---@param params number[]
function type3:action( fighter, skill,params)
    local teamIndex = params[2] == 1 and fighter.teamIndex or 3 - fighter.teamIndex;
    local site = params[3];
    local xOffset = params[4];
    local yOffset = params[5];
    local pos = fighter.fight.fightSites[teamIndex][site];
    local direction = teamIndex == 0 and Global.RIGHT or Global.LEFT;
    return Vector2(pos[1] + xOffset * direction, pos[3] + yOffset * direction);
end
---场中心
local type4 = ADD_VALUE("type4",4, "场中心")
---@param fighter Fighter
---@param skill FightUsingSkill
---@param params number[]
function type4:action( fighter, skill,params)
    local centerPosition = Global.FIGHT_CENTER_POSITION;
    local xOffset = 0;
    if (#params > 1) then
        xOffset = params[2];
    end
    local yOffset = 0;
    if (#params > 2) then
        yOffset = params[3];
    end
    return Vector2(centerPosition.x + xOffset, centerPosition.y + yOffset);
end
---以目标为中心 范围随机
local type5 = ADD_VALUE("type5",5, "范围随机")
---@param fighter Fighter
---@param skill FightUsingSkill
---@param params number[]
function type5:action( fighter, skill,params)
    local dis = math.abs(params[2]);
    local disMax = math.abs(params[3]);
    local randomRadis = fighter.fight:random(disMax - dis) + 1 + dis;
    local base = skill.target.position
    local vector2 = DistanceUtil.calInderectPoint(base.x, base.y, base.x + 1, base.y, randomRadis, fighter.fight:random(360), 1);
    return vector2;
end

--配置的位置
local type6 = ADD_VALUE("type6",6, "范围随机")
---@param fighter Fighter
---@param skill FightUsingSkill
---@param params number[]
function type6:action( fighter, skill,params)
    local index = fighter.teamIndex * 2 +1;
    return  Vector2.New(params[index],params[index+1]);
end
